home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Original Code / An Exercise in Text Output / SysInfoList / SysInfoList.cs next >
Encoding:
Text File  |  2001-01-15  |  1.4 KB  |  46 lines

  1. //------------------------------------------
  2. // SysInfoList.cs ⌐ 2001 by Charles Petzold
  3. //------------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7.  
  8. class SysInfoList: Form
  9. {
  10.      readonly float cxCol;
  11.      readonly int   cySpace;
  12.  
  13.      public static void Main()
  14.      {
  15.           Application.Run(new SysInfoList());
  16.      }
  17.      public SysInfoList()
  18.      {
  19.           Text = "System Information: List";
  20.           BackColor = SystemColors.Window;
  21.           ForeColor = SystemColors.WindowText;
  22.  
  23.           Graphics grfx  = CreateGraphics();
  24.           SizeF    sizef = grfx.MeasureString(" ", Font);
  25.           cxCol = sizef.Width + SysInfoStrings.MaxLabelWidth(grfx, Font);
  26.           grfx.Dispose();
  27.           cySpace = Font.Height;
  28.      }
  29.      protected override void OnPaint(PaintEventArgs pea)
  30.      {
  31.           Graphics grfx       = pea.Graphics;
  32.           Brush    brush      = new SolidBrush(ForeColor);
  33.           int      iCount     = SysInfoStrings.Count;
  34.           string[] astrLabels = SysInfoStrings.Labels;
  35.           string[] astrValues = SysInfoStrings.Values;
  36.  
  37.           for (int i = 0; i < iCount; i++)
  38.           {
  39.                grfx.DrawString(astrLabels[i], Font, brush, 
  40.                                0, i * cySpace);
  41.                grfx.DrawString(astrValues[i], Font, brush, 
  42.                                cxCol, i * cySpace); 
  43.           }
  44.      }
  45. }
  46.